﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using RaisingStudio.Xna.Graphics;

namespace WindowsGame1
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game2 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        DrawingContext drawingContext;
        SpriteFont spriteFont;
        Texture2D texture;

        public Game2()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            drawingContext = new DrawingContext(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("SegoeUI");
            texture = Content.Load<Texture2D>("Tulips");
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here

            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            // TODO: Add your drawing code here
            drawingContext.Begin();
            drawingContext.DrawLine(10, 20, 100, 20, Color.Red);
            drawingContext.DrawRectangle(120, 10, 100, 20, Color.Blue);
            drawingContext.DrawTriangle(240, 10, 240, 60, 200, 60, Color.Black);
            drawingContext.DrawEllipse(310, 10, 50, 50, Color.Green);
            drawingContext.DrawTexture(texture, new Vector2(10, 300), Color.White);
            drawingContext.DrawPolyline(new Vector2[] { new Vector2(410, 10), new Vector2(440, 10), new Vector2(420, 20), new Vector2(440, 40), new Vector2(410, 60) }, Color.Aqua);
            drawingContext.DrawFilledRectangle(120, 110, 50, 50, Color.Blue);
            drawingContext.DrawFilledTriangle(240, 110, 240, 160, 200, 160, Color.Brown);
            drawingContext.DrawFilledEllipse(310, 110, 80, 40, Color.Green);
            drawingContext.DrawText(spriteFont, "Hello World!", new Vector2(120, 300), Color.Black);
            drawingContext.End();

            base.Draw(gameTime);
        }
    }
}
